<template>
  <div class="top">
    <el-card>
      <div class="card">
        <el-form :inline="true">
          <el-form-item><el-input placeholder="请输入教师名称" v-model="keyword"></el-input></el-form-item>
          <el-form-item><el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button></el-form-item>
        </el-form>
      </div>
      <div class="add">
        <el-button type="success" @click="handleAdd" icon="el-icon-plus">添加</el-button>
      </div>
    </el-card>
    <el-card>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column type="selection" width="55"></el-table-column>
     <el-table-column fixed label="序号" align="center">
            <template slot-scope="scope">{{scope.$index + 1 }}</template>
    </el-table-column>
    <el-table-column label="楼栋名" align="center" property="building" ></el-table-column>
    <el-table-column label="宿舍号" align="center" property="dormitory"></el-table-column>
    <el-table-column label="宿舍成员" align="center" property="member"></el-table-column>
    <el-table-column label="舍长" align="center" property="president"></el-table-column>
    <el-table-column label="是否为空" align="center" property="isdelete"></el-table-column>
    <el-table-column label="操作"  fixed="right" align="center" width="150">
          <template slot-scope="scope">
            <el-button size="mini" type="warning" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
    </el-table>
   <div>
        <el-dialog :visible.sync="dialogFormVisible">
          <el-form :model="form" :rules="rules" ref="formDemo">
            <el-form-item label="楼栋名:" :label-width="formLabelWidth" prop="building">
              <el-input v-model="form.teacher" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="宿舍号:" :label-width="formLabelWidth" prop="dormitory">
              <el-input v-model="form.cardid" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="宿舍成员:" :label-width="formLabelWidth" prop="member">
              <el-input v-model="form.college" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="舍长:" :label-width="formLabelWidth" prop="president">
              <el-input v-model="form.phone" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="是否为空:" :label-width="formLabelWidth" prop="isdelete">
               <el-radio v-model="form.isdelete" label=true >是</el-radio>
                <el-radio v-model="form.isdelete"  label=false >否</el-radio>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="handleCancel">取 消</el-button>
            <el-button type="primary" @click="handleSave">确 定</el-button>
          </div>
        </el-dialog>
      </div>
    </el-card>
    <div>
        <el-pagination
            :current-page="pager.pageIndex"
            :page-size="pager.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pager.rowsTotal"
            background
        >
        </el-pagination>
    </div>
  </div>  
</template>

<script>
export default{
    data(){
        return{
            keyword:'',
            tableData:[],
            dialogFormVisible: false,
            formLabelWidth:"120px",
            form:{
                building:'',
                dormitory:'',
                member:'',
                president:'',
                isdelete:'',
            },
            rules:{
        building:[
        {
            required: true,
            trigger: "blur",
            message: "请输入宿舍楼",
        },
        ],
        dormitory:[
        {
            required: true,
            trigger: "blur",
            message: "请输入宿舍号",
        },
        ],
        member:[
        {
            required: true,
            trigger: "blur",
            message: "请输入宿舍成员",
        },
        ],
        president:[
        {
            required: true,
            trigger: "blur",
            message: "请输入舍长姓名",
        },
        ],
        isdelete:[
          {
             required: true,
            trigger: "blur",
            message: "请选择是否为空",
          }
        ]
      },
            pager:{
            pageIndex:1,
            rowsTotal:100,
      },
        }
    },
    methods:{
        handleQuery(){
          if(this.keyword == ""){
            this.$message.warning("查询条件不能为空");
            this.keyword = "";
            return
          }
          console.log("你输入的查询条件:"+this.keyword);
        },
        handleAdd(){
            this.dialogFormVisible = true;
        },
        handleEdit(){
            this.dialogFormVisible = true;
        },
        handleCancel() {
        this.dialogFormVisible = false;
        },
        handleSave() {
      this.dialogFormVisible = false;
    },
    }
}

</script>
<style scoped>
.top {
  width: 100%;
  height: 100%;
}
.card{
    width: 100%;
  height: 100%;
}
</style>
<style>
.el-card__body {
  display: flex;
  justify-content: space-between;
}
.el-form-item__label{
  font-size: 18px;
 font-weight: bolder;
}
.el-table-column{
  width: auto;
}
</style>
